package com.sx.manage.controller.company;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.ServletException;

import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.company.MerchantCompanyWebServiceImpl;
import com.sx.manage.servlet.ViewAndModel;
import com.sx.model.manage.mybatis.form.helps.MerchantCompanyInfoForm;
import com.sx.model.manage.mybatis.vo.result.ResultBooleanVO;
/**
 * 商户关系
 * @author zwm
 *
 */
@RestController
@RequestMapping("/merchant")
public class MerchantController extends MBaseController{
	
	
	@Resource(name="merchantCompanyWebServiceImpl")
	private MerchantCompanyWebServiceImpl merchantCompanyWebServiceImpl;
	
	@RequestMapping(value="merchantRelation/{id}")
	@ResponseBody
	public ViewAndModel add_viewCompany(@PathVariable Long id){
		ViewAndModel viewAndModel = new ViewAndModel(request,cache);
		merchantCompanyWebServiceImpl.add_viewCompany(viewAndModel,id);
		viewAndModel.setViewName("company/merchant/shopping_manage_company");
		return viewAndModel;
	}
	
	/**
	 * 添加公司数据信息
	 * @param request
	 * @param response
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping("/merchantRelationSave")
	public ResultBooleanVO save_merchant_relation(MerchantCompanyInfoForm form ,BindingResult errors){
		return merchantCompanyWebServiceImpl.add_merchant_company(form, this.loginConsumer());	
	}

}
